/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tencent.tendon.convert.json;

import com.tencent.tendon.convert.util.Creator;
import java.lang.reflect.Type;

/**
 *
 * @author nbzhang
 */
public abstract class JsonDecoder<T> implements JsonDecodable<T> {

    protected final Type type;

    protected final Creator<T> creator;

    protected boolean simpled;

    public JsonDecoder(Type type) {
        this.type = type;
        this.creator = ((type instanceof Class) && !((Class) type).isArray()) ? JsonFactory.loadCreator((Class) type) : null;
    }

    @Override
    public abstract T convertFrom(final JsonReader reader);

    @Override
    public final Type getType() {
        return this.type;
    }

    @Override
    public final boolean isSimpled() {
        return this.simpled;
    }
}
